#pragma once

#include "Sol9Types.h"

namespace sol9
{

	class CRTTI
	{
	private:
		const std::tstring m_strClassName;
		const CRTTI* m_pParent;

	public:
		// constructor
		CRTTI(const std::tstring& strClassName, const CRTTI* pParent = NULL)
			: m_strClassName(strClassName), m_pParent(pParent) {}

		// functions
		bool isDerivedFrom(const CRTTI& Other) const
		{
			const CRTTI* pCurr = this;
			
			while (pCurr)
			{
				if (pCurr == &Other)
				{
					return true;
				}

				pCurr = pCurr->getParent();
			}

			return false;
		}

		bool isDerivedFrom(const std::tstring& strOther)
		{
			const CRTTI* pCurr = this;

			while (pCurr)
			{
				if (pCurr->m_strClassName == strOther)
				{
					return true;
				}

				pCurr = pCurr->getParent();
			}
			
			return false;
		}

		// operators
		const std::tstring& getClassName() const
		{
			return m_strClassName;
		}

		const CRTTI* getParent() const
		{
			return m_pParent;
		}
	};

#include "RTTI_macros.h"

} // namespace sol9